<?php

require __DIR__.'/../../../vendor/autoload.php';

use Gateway\EsBalanceResponse;
use Gateway\ESGateway;
use Gateway\EsBalanceRequest;
use Gateway\JSONUtil;
use Gateway\Log;

$appCode = "d2808c1338ce01f3e3efdb486f9effb9";
$algo = "3";
$key = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEhdQdw6uTGz+X4e+/eGpu4dcKrfrjQAe0tTQyn6TuKBobcsUsESkx9jcCeG4cpuxmN8jNeDAZsbTujNLD/aYl2g==";
$esGateway = new ESGateway($appCode, $algo, $key);

// 调用通用接口查询余额,文档: https://esandinfo.yuque.com/yv6e1k/aa4qsg/la1w7otq7vg00i1g
$esBalanceRequest = new EsBalanceRequest("");
$gatewayResponse = $esGateway->sendToGateWay(EsBalanceRequest::$act,$esBalanceRequest->toJsonStr());
Log::DEBUG("服务器返回数据：".$gatewayResponse->toJsonStr());
if ($gatewayResponse->bizContent != null) {
    Log::DEBUG("业务数据为：".$gatewayResponse->bizContent);
    $rsp = JSONUtil::fromJsonStr($gatewayResponse->bizContent);
    // TODO 业务处理
}
